#include "SlidingDict.h"


// 构造
CSlidingDict::CSlidingDict(const size_t size)
{
    this->m_allocate = (byte*)malloc(size);
    this->m_curp = this->m_allocate;
    memset(this->m_allocate, 0, size);

    this->m_dictSize = size;
    this->m_curSize = 0;
    this->m_curPos = 0;
}

// 析构
CSlidingDict::~SlidingDict()
{
    free(this->m_allocate);
    this->m_allocate = NULL;
}

// 添加字符
void CSlidingDict::operator +(const byte meta)
{
    if (this->m_curPos == this->m_dictSize)
    {
        this->m_curp = this->m_allocate;
        this->m_curPos = 0;
    }

    memcpy(this->m_curp, &item, 1);
    this->m_curp += 1;
    this->m_curPos = (this->m_curPos + 1) % this->m_dictSize;

    this->m_curSize += 1;
}

// 添加字符串
void CSlidingDict::operator +(const byte* meta)
{
    while (meta)
        this->operator +(*(meta++));
}

// 下标运算
byte CSlidingDict::operator [](const size_t pos)
{
    size_t cur_pos = (pos + this->m_curPos) % this->m_dictSize;
    return this->m_allocate[cur_pos];
}

// 下标运算
size_t* CSlidingDict::operator [](const byte* value)
{

}
